package com.liu.demo1.testDemo;

/**
 * @author liusiyu
 * @ClassName Singleton
 * @date 2022年02月10日 17:32
 */
public class Singleton {
    //懒汉单例模式
    private static volatile Singleton singleton;

    private Singleton(){}

    public static Singleton getSingleton(){
        if (singleton == null){
            synchronized (Singleton.class){
                if (singleton == null){
                    singleton = new Singleton();
                }
            }
        }
        return singleton;
    }

}
